package com.lj.graduate.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lj.graduate.controller.dto.OrderDTO;
import com.lj.graduate.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ljy
 * @since 2023-03-24
 */
public interface OrderMapper extends BaseMapper<Order> {
    @Select("select order_id,scenic_detail.scenic_name,user_name,order_time,payment_method,orders.price from orders " +
            "Inner Join `user` on orders.user_id = `user`.user_id " +
            "Inner Join scenic_detail on orders.scenic_id = scenic_detail.scenic_id limit #{pageNum}, #{pageSize}")
    List<OrderDTO> selectPage(Integer pageNum, Integer pageSize);

    @Select("SELECT SUM(price) AS sum FROM orders")
    int sumPrice();
}
